<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('村民购煤订单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">

        <div class="row">
            <div class="col-sm-12 search-collapse">

                <div class="row">
                </div>
                <form id="formId">
                    <input id="villageId" type="hidden" th:value="${user.deptId}">
                    <input id="status" type="hidden" th:value="1">
                    <div class="select-list">
                        <p>
                            <label th:text="'本批次购煤数量  '+${sumOrder?.amount == null ? '0' : sumOrder?.amount}+'吨'"></label>
                            <label th:text="'已付购煤款   '+${sumOrder?.money == null ? '0' : sumOrder?.money}+'元'"></label>
                            <a class="btn btn-success btn-sm" onclick="purchase()">集中购煤</a>
                            <a class="btn btn-success btn-sm" onclick="purchaseRecord()">购煤记录</a>
                        </p>
                        <ul>
                            <li>
                                <label>查找：</label>
                                <input type="text" name="keyword"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()">
                    <i class="fa fa-plus"></i> 居民购煤信息录入
                </a>
            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jjm:clientUserorder:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jjm:clientUserorder:remove')}]];
        var prefix = ctx + "jjm/clientUserorder";

        $(function() {
            var options = {
                url: prefix + "/list?status=1&villageId="+[[${user.deptId}]],
                updateUrl: prefix + "/edit/{id}?type=1",
                createUrl: prefix + "/add/{id}",
                exportUrl: prefix + "/export",
                modalName: "居民购煤信息",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                columns: [
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                    {
                        title: "编号",
                        formatter: function (value, row, index) {
                            return $.table.serialNumber(index);
                        }
                    },
                {
                    field: 'clientUser.masterName',
                    title: '户主姓名'
                },
                {
                    field: 'clientUser.masterIdentityCardNumber',
                    title: '身份证号'
                },
                {
                    field: 'amount',
                    title: '购煤数量（吨）'
                },
                {
                    field: 'money',
                    title: '购煤款'
                },
                {
                    field: 'createTime',
                    title: '购煤时间',
                    formatter: function(value, row, index) {
                        return new Date(value).format("yyyy-MM-dd");
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>错误信息修改</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function purchase() {
            var amount = [[${sumOrder?.amount}]];
            if(amount && amount > 0){
                $.modal.openTab("集中购煤",prefix+"/purchase");
            }else{
                $.modal.alertWarning("本批次暂未购煤");
            }
        }
        function purchaseRecord() {
            $.modal.openTab("购煤记录","/jjm/order?villageId="+$("#villageId").val());
        }
    </script>
</body>
</html>